import redis

class BuyQueue:
    
    def __init__(self):
        self.db = redis.Redis(host="192.168.1.65", port=6379, db=0,decode_responses=True)
    
    def push(self, data) -> None:
        self.db.rpush("deal", data)
        
    def peek(self):
        return self.db.lpop("deal")
    
    def delete(self, data):
        return self.db.lrem("deal", 1, data)
    
    def index(self,index):
        return self.db.lindex("deal",index)
    
    def update(self, index,data):
        return self.db.lset("deal",index, data)
    
    # 判断是否执行完毕
    def empty(self):
        return self.db.llen("deal")

